package ms.jasim.framework;

import ms.jasim.framework.IEvaluator.Info;

public class EvaluatorResult {
	private ms.jasim.framework.IEvaluator.Info evalInfo;
	private float[] values;
	
	public EvaluatorResult(Class<? extends ms.jasim.framework.IEvaluator> evalClass, float[] values) {
		evalInfo = evalClass.getAnnotation(IEvaluator.Info.class);
		this.values = values.clone();
	}

	public EvaluatorResult(Info evalInfo, float[] values) {
		this.evalInfo = evalInfo;
		this.values = values.clone();
	}

	@Override
	public EvaluatorResult clone() {
		return new EvaluatorResult(evalInfo, values);
	}

	public String getName() {
		return evalInfo.Name();
	}
	
	public String getDescription() {
		return evalInfo.Description();
	}
	
	public String[] getComponents() {
		return evalInfo.Components();
	}
	
	public float getValue() {
		return getValue("Value");	
	}
	
	public float getValue(String component) {
		for (int i = 0; i < getComponents().length; i++)
			if (getComponents()[i].equalsIgnoreCase(component))
				return values[i];
				
		return Float.NaN;
	}


	public float getValue(int idx) {
		return idx >= 0 && idx < values.length ? values[idx] : Float.NaN;
	}
	
	public void setValue(int idx, float value) {
		values[idx] = value;
	}
}
